import {TableConfig} from "vj-tool/vj-tool/types";
import {genFormOptions} from "vijay-util";

export const RiskTB: TableConfig = [
    {propName: "name", label: "项目"},
    {propName: "value", label: "最大值", cmp: "number"},
    {propName: "blacklist", label: "黑名单", cmp: "switch"},
    {propName: "reauth", label: "重新登录", cmp: "switch"},
    {propName: "notice", label: "短信报警", cmp: "switch"},
]
export const GameTB: TableConfig = [
    {propName: "id", label: "游戏ID"},
    {propName: "name", label: "游戏名称"},
    {propName: "coverUrl", label: "游戏示图", cmp: "img"},
    {propName: "remark", label: "备注"},
    {propName: "status", label: "状态", cmp: "switch"},
    {propName: "isOpenSensitive", label: "脱敏", cmp: "switch"},
    {propName: "createTime", label: "创建时间"},
]
export const WordTB: TableConfig = [
    {propName: "name", label: "ID"},
    {propName: "name", label: "类型"},
    {propName: "name", label: "敏感词"},
    {propName: "xx", label: "状态", cmp: "switch"},
]
export const LogTB: TableConfig = [
    {propName: "id", label: "ID"},
    {propName: ["username", "userId"], label: "昵称（ID）", cmp: "multiple"},
    {propName: "createTime", label: "操作时间"},
    {propName: "ip", label: "IP"},
    {propName: "operation", label: "操作类型"},
    {propName: "params", label: "详情"},
]
export const ScheduleTB: TableConfig = [
    {propName: "jobName", label: "任务名称"},
    {propName: "jobGroup", label: "任务组"},
    {propName: "jobDescription", label: "任务描述"},
    {propName: "jobStatus", label: "任务状态", cmp: "tag"},
    {propName: "cronExpression", label: "表达式"},
    {propName: "createTime", label: "创建时间"},
]
export const OrderTB = (type) => dynamicTable([
    {propName: "id", label: "ID"},
    {propName: "orderId", label: "订单号"},
    {propName: ["nickname", "memberId"], label: "用户(ID)", cmp: "multiple"},
    {propName: "gameName", label: "游戏"},
    {
        propName: "awardValue",
        label: "积分",
        formatter: ({awardValue, integralType}) => `${integralType ? '+' : "-"}${awardValue}`
    },
    [{propName: "repairNum", label: "累计补单次数"}, +type, 1],
    {propName: "createTime", label: "创建时间"},
])
function dynamicTable(arr: TableConfig): TableConfig {
    return (<any>arr).reduce((acc, cur) => {
        const notAllow = Array.isArray(cur) && cur[1] !== cur[2];
        Array.isArray(cur) && (cur = cur[0]);
        return notAllow ? acc : acc.concat(cur)
    }, [])
}
